
<link rel="stylesheet" href="components/com_kinh_doanh/assets/jquery-ui.css"/>
<script language="javascript" src="components/com_kinh_doanh/assets/jquery-1.8.2.js"></script>
<script language="javascript" src="components/com_kinh_doanh/assets/jquery-ui.js"></script>
<script>
    $(function() {
        $( "#datepicker" ).datepicker();
    });
    $("#datepicker").change(function(){
        alert("sss");
    })
</script>
<?php
	jimport('joomla.application.component.view');
	class kinh_doanhViewsu_luoc_ban_hang extends JView
	{
            //hien thi danh sach san pham
		function display($tpl=null)
        { 
            ?>
            
            
            <?php
            if(isset($_POST['datepicker']))
            {
                $date = $_POST['datepicker'];
            }
            else
            {
                $date = null;
            }
            
           $model = $this->getModel();
            $data=$model->su_luoc_ban_hang($date);
            //print_r($data);
           $tong_tien_truoc_den_gio = $model->tong_tien_truoc_den_gio();
           echo "Tổng doanh thu: ";
           //$tong_tien_truoc_den_gio = floor($tong_tien_truoc_den_gio);
           echo number_format($tong_tien_truoc_den_gio, 0, ',', '.');
           echo "<br/>";
           echo "Doanh thu trong ngày: ";$tong_tien_trong_ngay = $model->tong_tien_trong_ngay();
           echo  number_format($tong_tien_trong_ngay, 0, ',', '.');
           echo "<br />";
           echo "Số tiền tại chi nhánh: "; $tien_chi_nhanh = $model->tien_tai_chi_nhanh();
           echo  number_format($tien_chi_nhanh, 0, ',', '.');
		  ?> <form method="post" action="index.php/?option=com_kinh_doanh&task=su_luoc_ban_hang"><p>Date:<input type="text" id="datepicker" name="datepicker" value="<?php echo $date;?>"/><input type="submit" value="Gửi" /></p></form><?
           
           ?>
           <table border="1">
            <tr>
                <td>
                    Tên Sản Phẩm
                </td>
                 <td>
                    Mã Khách Hàng
                </td>
                <td>
                    Mã Cuppon
                </td>
                <td>
                    Số Lượng
                </td>
                <td>
                    Tổng Tiền
                </td>
                <td>
                    Ngày Mua
                </td>
                <td>
                    Ghi Chú
                </td>
                <?php
                        $ngay = date('Y-m-d');
                        //echo $ngay;
                        //echo "<br />";
                        
                       //echo $date;
                        //die;
                        if($date == $ngay || $date==NULL){?>
                <td>
                    Thao Tác
                </td><?php }?>
            </tr>
            <?php 
            foreach($data as $row)
            {
                ?>
                <tr>
                <td>
                    <?php if($row->name_product != "")echo $row->name_product;
                            else echo "Đơn hàng phụ thu."?>
                </td>
                 <td>
                     <?php if($row->id_customer != "")echo $row->id_customer;
                            else echo "Khách vãng lai."?>
                </td>
                <td>
                    <?php if($row->code_cuppon !="")echo $row->code_cuppon;
                            else echo "Không có."?>
                </td>
                <td>
                    <?php echo $row->number_of;?>
                </td>
                <td>
                    <?php 
                        //$tt = substr($row->total,0;
                    echo number_format($row->total, 0, ',', '.');
                    if($row->currency == "")
                        echo "(VNĐ)";
                    else
                        echo "(".$row->currency.")";
                    
                    ?>
                </td>
                <td>
                    <?php echo $row->date;?>
                </td>
                <td>
                    <?php echo $row->note;?>
                </td>
                <?php
                        $ngay = date('Y-m-d');
                        //echo $ngay;
                        //echo "<br />";
                        
                        $d = substr($row->date,0,10); //echo $d;
                        //die;
                        if($d == $ngay){?>
                <td>
                    <a href="index.php/?option=com_kinh_doanh&task=xoa_don_hang&id=<?php echo $row->id;?>">Xóa</a>
                </td><?php }?>
            </tr>
                <?php
            }
            ?>
           </table>
           <?php
		}
    }
?>